package com.ccnu.sb.exception;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.HashMap;
import java.util.Map;

public class RspException extends RuntimeException {
	/**
	 * 
	 */
	private static final long serialVersionUID = 7565063039885347604L;
	public RspException(String rspCode, String rspMsg) {
		super();
		this.rspCode = rspCode;
		this.rspMsg = rspMsg;
	}
	private String rspCode;
	private String rspMsg;
	public String getRspCode() {
		return rspCode;
	}
	public void setRspCode(String rspCode) {
		this.rspCode = rspCode;
	}
	public String getRspMsg() {
		return rspMsg;
	}
	public void setRspMsg(String rspMsg) {
		this.rspMsg = rspMsg;
	}
	public String getErrorInfo() {
		Map<String, String> rspMap = new HashMap<String, String>();
		rspMap.put("rspCode", this.getRspCode());
		rspMap.put("rspMsg", this.getRspMsg());
		
		ObjectMapper mapper = new ObjectMapper();
		String rspString = "";
		try {
			rspString = mapper.writeValueAsString(rspMap);
		} catch (JsonProcessingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return rspString;
	}
}
